F# codegen: FluentValidation + CosmosDB slice — runnable sample + compile-gate (GH-2969)#2986
Merged
Merged
Conversation
A combined F# Wolverine sample exercising two middleware surfaces in one handler (requested by Jeremy), plus a compile-gate proving the chain emits valid F#. Frame F# emit (the only one that needed it): - CosmosDb TransactionalFrame -> `context.EnlistInOutbox(CosmosDbEnvelopeTransaction(container, context))` (EnlistInOutbox is synchronous; CosmosDbEnvelopeTransaction is public). Everything else was already F#: - FluentValidation -> `do! FluentValidationExecutor.ExecuteOne<T>(validator, failureAction, msg)` (MethodCall). - ISideEffect (ICosmosDbOp) -> `if not (isNull outgoing1) then do! outgoing1.Execute(container)`. - Outbox flush -> `do! context.FlushOutgoingMessagesAsync()`. Runnable sample (src/Samples/WolverineCosmosFSharpSample): - F# CreateThing command + CreateThingValidator (AbstractValidator<CreateThing>; F# auto-converts the RuleFor property-selector lambdas to LINQ expression trees) + a [<Transactional>] CreateThingHandler returning CosmosDbOps.Store(thing). UseFluentValidation() + UseCosmosDbPersistence(db). Runs via dynamic codegen (Wolverine.RuntimeCompilation + UseRuntimeCompilation, GH-2876) against the Cosmos emulator (pre-creates the database, since resource setup only creates containers). Verified end-to-end: "Stored a Thing through the F# Wolverine + CosmosDB handler (with FluentValidation)." Compile-gate (src/Testing/Wolverine.Cosmos.FSharp{Tests,Fixture}): - Renders the sample's real CreateThing chain to F# via the no-host HandlerGraph/AssembleTypes/GenerateFSharpCode path and dotnet-builds the fixture. No live Cosmos connection (the CosmosClient is constructed lazily and never used at codegen). Wire-up: sample + gate added to wolverine_fsharp.slnx; fsharp.yml runs the gate as its own sequential step. No JasperFx release needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
8 tasks
This was referenced Jun 1, 2026
Merged
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the F# code-generation audit (#2969). A combined F# sample exercising two middleware surfaces in one handler — FluentValidation + CosmosDB persistence — plus a compile-gate proving the chain emits valid F#.
Frame F# emit
Only one frame needed new F# emit:
TransactionalFrame→context.EnlistInOutbox(CosmosDbEnvelopeTransaction(container, context))(EnlistInOutboxis synchronous;CosmosDbEnvelopeTransactionis already public).Everything else was already F# via
MethodCall/existing frames:do! FluentValidationExecutor.ExecuteOne<T>(validator, failureAction, msg).ISideEffect(the returnedICosmosDbOp) →if not (isNull outgoing1) then do! outgoing1.Execute(container).do! context.FlushOutgoingMessagesAsync().Generated F# (from the gate):
Runnable sample —
src/Samples/WolverineCosmosFSharpSampleF#
CreateThingcommand +CreateThingValidator : AbstractValidator<CreateThing>+ a[<Transactional>]CreateThingHandlerreturningCosmosDbOps.Store(thing).UseFluentValidation()+UseCosmosDbPersistence(db). Runs via dynamic codegen (Wolverine.RuntimeCompilation+opts.UseRuntimeCompilation(), #2876) against the Cosmos emulator (the sample pre-creates the database, since Wolverine's resource setup only creates containers). Verified end-to-end: printsStored a Thing through the F# Wolverine + CosmosDB handler (with FluentValidation).F# + FluentValidation note
AbstractValidator<T>.RuleFortakes a LINQExpression<Func<T,TProperty>>; F# auto-converts the property-selector lambdas (fun x -> x.Name) to expression trees, so the validator reads naturally.Compile-gate —
src/Testing/Wolverine.Cosmos.FSharp{Tests,Fixture}Renders the sample's real
CreateThingchain to F# via the no-hostHandlerGraph→AssembleTypes→GenerateFSharpCodepath, thendotnet builds the fixture. No live Cosmos connection (theCosmosClientis constructed lazily and never used at codegen).Wire-up
wolverine_fsharp.slnx.fsharp.ymlruns the FluentValidation + CosmosDB gate as its own sequential step.Verification
dotnet build wolverine.slnx -c Releaseclean (per CLAUDE.md the slim build isn't sufficient).🤖 Generated with Claude Code